#include "public.h"
#include "key.h"
#include "smg.h"
#include "24c02.h"

#define EEPROM_ADDRESS 0

void main()
{
    unsigned char key_temp = 0;
    unsigned char save_value = 0;
    unsigned char save_buf[3];
    while(1)
    {
        key_temp = which_key_press();
        if (key_temp == 1)
        {
            at24c02_write_one_byte(EEPROM_ADDRESS,save_value);
        }
        else if (key_temp == 2)     
        {
            save_value = at24c02_read_one_byte(EEPROM_ADDRESS);
        }
         else if (key_temp == 3)     
        {
            save_value++;
            if (save_value == 255)
            {
                save_value=255;
            }
        }
         else if (key_temp == 4)     
        {
            save_value = 0;
        }
        save_buf[0]=save_value/100;
        save_buf[1]=save_value%100/10;
        save_buf[2]=save_value%100%10;
        smg_display(save_buf,6);
    }
}